﻿using PokemonBattle.BattleRoom.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PBO.RoomClient
{
    internal static class StringHelper
    {
        public static void InvokeAppendText(this TextBox tb, string s)
        {
            if (!tb.InvokeRequired)
            {
                if (tb.TextLength > 0) tb.AppendText("\r\n");
                tb.AppendText(s);
                tb.SelectionStart = tb.Text.Length - 1;
                tb.ScrollToCaret();
            }
            else
            {
                tb.Invoke(new Action(delegate { InvokeAppendText(tb, s); }));
            }
        }

        public static string GetStateString(this UserState state)
        {
            switch (state)
            {
                case UserState.Free:
                    return "空闲";
                case UserState.Battling:
                    return "对战中";
                case UserState.Away:
                    return "离开";
                case UserState.Challenging:
                    return "挑战中";
                default:
                    return string.Empty;
            }
        }
    }
}
